#[doc = "Register `PERI_PMC30` reader"]
pub struct R(crate::R<PERI_PMC30_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<PERI_PMC30_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<PERI_PMC30_SPEC>> for R {
    fn from(reader: crate::R<PERI_PMC30_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `PERI_PMC30` writer"]
pub struct W(crate::W<PERI_PMC30_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<PERI_PMC30_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::ops::DerefMut for W {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}
impl core::convert::From<crate::W<PERI_PMC30_SPEC>> for W {
    fn from(writer: crate::W<PERI_PMC30_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "hpm1_monitor_period.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HPM2_RST_REQ_A {
    #[doc = "0: disabled."]
    DISABLED = 0,
    #[doc = "1: enabled."]
    ENABLED = 1,
}
impl From<HPM2_RST_REQ_A> for bool {
    #[inline(always)]
    fn from(variant: HPM2_RST_REQ_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `hpm2_rst_req` reader - hpm1_monitor_period."]
pub struct HPM2_RST_REQ_R(crate::FieldReader<bool, HPM2_RST_REQ_A>);
impl HPM2_RST_REQ_R {
    pub(crate) fn new(bits: bool) -> Self {
        HPM2_RST_REQ_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HPM2_RST_REQ_A {
        match self.bits {
            false => HPM2_RST_REQ_A::DISABLED,
            true => HPM2_RST_REQ_A::ENABLED,
        }
    }
    #[doc = "Checks if the value of the field is `DISABLED`"]
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        **self == HPM2_RST_REQ_A::DISABLED
    }
    #[doc = "Checks if the value of the field is `ENABLED`"]
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        **self == HPM2_RST_REQ_A::ENABLED
    }
}
impl core::ops::Deref for HPM2_RST_REQ_R {
    type Target = crate::FieldReader<bool, HPM2_RST_REQ_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `hpm2_rst_req` writer - hpm1_monitor_period."]
pub struct HPM2_RST_REQ_W<'a> {
    w: &'a mut W,
}
impl<'a> HPM2_RST_REQ_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: HPM2_RST_REQ_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "disabled."]
    #[inline(always)]
    pub fn disabled(self) -> &'a mut W {
        self.variant(HPM2_RST_REQ_A::DISABLED)
    }
    #[doc = "enabled."]
    #[inline(always)]
    pub fn enabled(self) -> &'a mut W {
        self.variant(HPM2_RST_REQ_A::ENABLED)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 27)) | (((value as u32) & 0x01) << 27);
        self.w
    }
}
#[doc = "HPM2 cyclic monitoring enable.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HPM2_MONITOR_EN_A {
    #[doc = "0: disabled."]
    DISABLED = 0,
    #[doc = "1: enabled."]
    ENABLED = 1,
}
impl From<HPM2_MONITOR_EN_A> for bool {
    #[inline(always)]
    fn from(variant: HPM2_MONITOR_EN_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `hpm2_monitor_en` reader - HPM2 cyclic monitoring enable."]
pub struct HPM2_MONITOR_EN_R(crate::FieldReader<bool, HPM2_MONITOR_EN_A>);
impl HPM2_MONITOR_EN_R {
    pub(crate) fn new(bits: bool) -> Self {
        HPM2_MONITOR_EN_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HPM2_MONITOR_EN_A {
        match self.bits {
            false => HPM2_MONITOR_EN_A::DISABLED,
            true => HPM2_MONITOR_EN_A::ENABLED,
        }
    }
    #[doc = "Checks if the value of the field is `DISABLED`"]
    #[inline(always)]
    pub fn is_disabled(&self) -> bool {
        **self == HPM2_MONITOR_EN_A::DISABLED
    }
    #[doc = "Checks if the value of the field is `ENABLED`"]
    #[inline(always)]
    pub fn is_enabled(&self) -> bool {
        **self == HPM2_MONITOR_EN_A::ENABLED
    }
}
impl core::ops::Deref for HPM2_MONITOR_EN_R {
    type Target = crate::FieldReader<bool, HPM2_MONITOR_EN_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `hpm2_monitor_en` writer - HPM2 cyclic monitoring enable."]
pub struct HPM2_MONITOR_EN_W<'a> {
    w: &'a mut W,
}
impl<'a> HPM2_MONITOR_EN_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: HPM2_MONITOR_EN_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "disabled."]
    #[inline(always)]
    pub fn disabled(self) -> &'a mut W {
        self.variant(HPM2_MONITOR_EN_A::DISABLED)
    }
    #[doc = "enabled."]
    #[inline(always)]
    pub fn enabled(self) -> &'a mut W {
        self.variant(HPM2_MONITOR_EN_A::ENABLED)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 26)) | (((value as u32) & 0x01) << 26);
        self.w
    }
}
#[doc = "Single-time HPM2 enable signal.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HPM2_BYPASS_A {
    #[doc = "0: The start signal of HPM2 is determined by \\[hpm2_monitor_en\\]."]
    BY_MONITOR = 0,
    #[doc = "1: The start signal of the HPM2 is determined by \\[hpm2_en\\]."]
    BY_PERIPHERAL = 1,
}
impl From<HPM2_BYPASS_A> for bool {
    #[inline(always)]
    fn from(variant: HPM2_BYPASS_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `hpm2_bypass` reader - Single-time HPM2 enable signal."]
pub struct HPM2_BYPASS_R(crate::FieldReader<bool, HPM2_BYPASS_A>);
impl HPM2_BYPASS_R {
    pub(crate) fn new(bits: bool) -> Self {
        HPM2_BYPASS_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HPM2_BYPASS_A {
        match self.bits {
            false => HPM2_BYPASS_A::BY_MONITOR,
            true => HPM2_BYPASS_A::BY_PERIPHERAL,
        }
    }
    #[doc = "Checks if the value of the field is `BY_MONITOR`"]
    #[inline(always)]
    pub fn is_by_monitor(&self) -> bool {
        **self == HPM2_BYPASS_A::BY_MONITOR
    }
    #[doc = "Checks if the value of the field is `BY_PERIPHERAL`"]
    #[inline(always)]
    pub fn is_by_peripheral(&self) -> bool {
        **self == HPM2_BYPASS_A::BY_PERIPHERAL
    }
}
impl core::ops::Deref for HPM2_BYPASS_R {
    type Target = crate::FieldReader<bool, HPM2_BYPASS_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `hpm2_bypass` writer - Single-time HPM2 enable signal."]
pub struct HPM2_BYPASS_W<'a> {
    w: &'a mut W,
}
impl<'a> HPM2_BYPASS_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: HPM2_BYPASS_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "The start signal of HPM2 is determined by \\[hpm2_monitor_en\\]."]
    #[inline(always)]
    pub fn by_monitor(self) -> &'a mut W {
        self.variant(HPM2_BYPASS_A::BY_MONITOR)
    }
    #[doc = "The start signal of the HPM2 is determined by \\[hpm2_en\\]."]
    #[inline(always)]
    pub fn by_peripheral(self) -> &'a mut W {
        self.variant(HPM2_BYPASS_A::BY_PERIPHERAL)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 25)) | (((value as u32) & 0x01) << 25);
        self.w
    }
}
#[doc = "Single HPM2 measurement enable.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HPM2_EN_A {
    #[doc = "0: The value is retained 0 before a process is started."]
    RETAINED = 0,
    #[doc = "1: A frequency modulation process is started."]
    STARTED = 1,
}
impl From<HPM2_EN_A> for bool {
    #[inline(always)]
    fn from(variant: HPM2_EN_A) -> Self {
        variant as u8 != 0
    }
}
#[doc = "Field `hpm2_en` reader - Single HPM2 measurement enable."]
pub struct HPM2_EN_R(crate::FieldReader<bool, HPM2_EN_A>);
impl HPM2_EN_R {
    pub(crate) fn new(bits: bool) -> Self {
        HPM2_EN_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> HPM2_EN_A {
        match self.bits {
            false => HPM2_EN_A::RETAINED,
            true => HPM2_EN_A::STARTED,
        }
    }
    #[doc = "Checks if the value of the field is `RETAINED`"]
    #[inline(always)]
    pub fn is_retained(&self) -> bool {
        **self == HPM2_EN_A::RETAINED
    }
    #[doc = "Checks if the value of the field is `STARTED`"]
    #[inline(always)]
    pub fn is_started(&self) -> bool {
        **self == HPM2_EN_A::STARTED
    }
}
impl core::ops::Deref for HPM2_EN_R {
    type Target = crate::FieldReader<bool, HPM2_EN_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `hpm2_en` writer - Single HPM2 measurement enable."]
pub struct HPM2_EN_W<'a> {
    w: &'a mut W,
}
impl<'a> HPM2_EN_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: HPM2_EN_A) -> &'a mut W {
        self.bit(variant.into())
    }
    #[doc = "The value is retained 0 before a process is started."]
    #[inline(always)]
    pub fn retained(self) -> &'a mut W {
        self.variant(HPM2_EN_A::RETAINED)
    }
    #[doc = "A frequency modulation process is started."]
    #[inline(always)]
    pub fn started(self) -> &'a mut W {
        self.variant(HPM2_EN_A::STARTED)
    }
    #[doc = r"Sets the field bit"]
    #[inline(always)]
    pub fn set_bit(self) -> &'a mut W {
        self.bit(true)
    }
    #[doc = r"Clears the field bit"]
    #[inline(always)]
    pub fn clear_bit(self) -> &'a mut W {
        self.bit(false)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub fn bit(self, value: bool) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x01 << 24)) | (((value as u32) & 0x01) << 24);
        self.w
    }
}
#[doc = "Field `hpm2_offset` reader - Offset after the HPM2 original code word is shifted rightwards."]
pub struct HPM2_OFFSET_R(crate::FieldReader<u16, u16>);
impl HPM2_OFFSET_R {
    pub(crate) fn new(bits: u16) -> Self {
        HPM2_OFFSET_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for HPM2_OFFSET_R {
    type Target = crate::FieldReader<u16, u16>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `hpm2_offset` writer - Offset after the HPM2 original code word is shifted rightwards."]
pub struct HPM2_OFFSET_W<'a> {
    w: &'a mut W,
}
impl<'a> HPM2_OFFSET_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u16) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x03ff << 12)) | (((value as u32) & 0x03ff) << 12);
        self.w
    }
}
#[doc = "Field `hpm2_shift` reader - Number of right shift bits of the original HPM2 code word."]
pub struct HPM2_SHIFT_R(crate::FieldReader<u8, u8>);
impl HPM2_SHIFT_R {
    pub(crate) fn new(bits: u8) -> Self {
        HPM2_SHIFT_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for HPM2_SHIFT_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `hpm2_shift` writer - Number of right shift bits of the original HPM2 code word."]
pub struct HPM2_SHIFT_W<'a> {
    w: &'a mut W,
}
impl<'a> HPM2_SHIFT_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
        self.w
    }
}
#[doc = "Field `hpm2_div` reader - HPM2 clock divider."]
pub struct HPM2_DIV_R(crate::FieldReader<u8, u8>);
impl HPM2_DIV_R {
    pub(crate) fn new(bits: u8) -> Self {
        HPM2_DIV_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for HPM2_DIV_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `hpm2_div` writer - HPM2 clock divider."]
pub struct HPM2_DIV_W<'a> {
    w: &'a mut W,
}
impl<'a> HPM2_DIV_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x3f) | ((value as u32) & 0x3f);
        self.w
    }
}
impl R {
    #[doc = "Bit 27 - hpm1_monitor_period."]
    #[inline(always)]
    pub fn hpm2_rst_req(&self) -> HPM2_RST_REQ_R {
        HPM2_RST_REQ_R::new(((self.bits >> 27) & 0x01) != 0)
    }
    #[doc = "Bit 26 - HPM2 cyclic monitoring enable."]
    #[inline(always)]
    pub fn hpm2_monitor_en(&self) -> HPM2_MONITOR_EN_R {
        HPM2_MONITOR_EN_R::new(((self.bits >> 26) & 0x01) != 0)
    }
    #[doc = "Bit 25 - Single-time HPM2 enable signal."]
    #[inline(always)]
    pub fn hpm2_bypass(&self) -> HPM2_BYPASS_R {
        HPM2_BYPASS_R::new(((self.bits >> 25) & 0x01) != 0)
    }
    #[doc = "Bit 24 - Single HPM2 measurement enable."]
    #[inline(always)]
    pub fn hpm2_en(&self) -> HPM2_EN_R {
        HPM2_EN_R::new(((self.bits >> 24) & 0x01) != 0)
    }
    #[doc = "Bits 12:21 - Offset after the HPM2 original code word is shifted rightwards."]
    #[inline(always)]
    pub fn hpm2_offset(&self) -> HPM2_OFFSET_R {
        HPM2_OFFSET_R::new(((self.bits >> 12) & 0x03ff) as u16)
    }
    #[doc = "Bits 8:9 - Number of right shift bits of the original HPM2 code word."]
    #[inline(always)]
    pub fn hpm2_shift(&self) -> HPM2_SHIFT_R {
        HPM2_SHIFT_R::new(((self.bits >> 8) & 0x03) as u8)
    }
    #[doc = "Bits 0:5 - HPM2 clock divider."]
    #[inline(always)]
    pub fn hpm2_div(&self) -> HPM2_DIV_R {
        HPM2_DIV_R::new((self.bits & 0x3f) as u8)
    }
}
impl W {
    #[doc = "Bit 27 - hpm1_monitor_period."]
    #[inline(always)]
    pub fn hpm2_rst_req(&mut self) -> HPM2_RST_REQ_W {
        HPM2_RST_REQ_W { w: self }
    }
    #[doc = "Bit 26 - HPM2 cyclic monitoring enable."]
    #[inline(always)]
    pub fn hpm2_monitor_en(&mut self) -> HPM2_MONITOR_EN_W {
        HPM2_MONITOR_EN_W { w: self }
    }
    #[doc = "Bit 25 - Single-time HPM2 enable signal."]
    #[inline(always)]
    pub fn hpm2_bypass(&mut self) -> HPM2_BYPASS_W {
        HPM2_BYPASS_W { w: self }
    }
    #[doc = "Bit 24 - Single HPM2 measurement enable."]
    #[inline(always)]
    pub fn hpm2_en(&mut self) -> HPM2_EN_W {
        HPM2_EN_W { w: self }
    }
    #[doc = "Bits 12:21 - Offset after the HPM2 original code word is shifted rightwards."]
    #[inline(always)]
    pub fn hpm2_offset(&mut self) -> HPM2_OFFSET_W {
        HPM2_OFFSET_W { w: self }
    }
    #[doc = "Bits 8:9 - Number of right shift bits of the original HPM2 code word."]
    #[inline(always)]
    pub fn hpm2_shift(&mut self) -> HPM2_SHIFT_W {
        HPM2_SHIFT_W { w: self }
    }
    #[doc = "Bits 0:5 - HPM2 clock divider."]
    #[inline(always)]
    pub fn hpm2_div(&mut self) -> HPM2_DIV_W {
        HPM2_DIV_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "HPM2 reset request enable.\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [peri_pmc30](index.html) module"]
pub struct PERI_PMC30_SPEC;
impl crate::RegisterSpec for PERI_PMC30_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [peri_pmc30::R](R) reader structure"]
impl crate::Readable for PERI_PMC30_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [peri_pmc30::W](W) writer structure"]
impl crate::Writable for PERI_PMC30_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets PERI_PMC30 to value 0x0a"]
impl crate::Resettable for PERI_PMC30_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0x0a
    }
}
